package com.anysoft.web;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.webkit.WebView;

import com.anysoft.base.BaseWebviewWithCacheActivity;
import com.anysoft.event.TimeOutEvent;
import com.anysoft.utils.MentorLogger;

import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

/**
 * WebView 用于显示协议
 */
public class AgreementActivity extends BaseWebviewWithCacheActivity {

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        loadUrl = "file:///android_asset/html/" + getIntent().getStringExtra("html");
        title.setText("协议详情");
        // 设置可以支持缩放
        mWebView.getSettings().setSupportZoom(true);
        // 设置出现缩放工具
        mWebView.getSettings().setBuiltInZoomControls(true);
        // 为图片添加放大缩小功能
        mWebView.getSettings().setUseWideViewPort(true);
        MentorLogger.Log(TAG, "url=" + loadUrl);
        initView(loadUrl);
    }

    @Override
    protected void onResume() {
        super.onResume();
    }

    @Override
    protected void onPause() {
        super.onPause();
    }

    @Override
    public void onshouldOverrideUrlLoadingCallBack(WebView webview, String url) {

    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onTimeOutCallBack(TimeOutEvent event) {
        if (event.isSuccess) {
            finish();
        }
    }


    @Override
    protected void onDestroy() {
        super.onDestroy();
    }
}
